home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Halma 1.1.source Folder / Halma ƒ / Halma code ƒ / halma endgame.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-23  |  3.1 KB  |  123 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        halma endgame.c
  4.  
  5. Purpose:    This module handles drawing the endgame board.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program in a file named "GNU General Public License".
  19. If not, write to the Free Software Foundation, 675 Mass Ave,
  20. Cambridge, MA 02139, USA.
  21.  
  22. \**********************************************************************/
  23.  
  24. #include "halma endgame.h"
  25. #include "halma meat.h"
  26. #include "program globals.h"
  27. #include "sounds.h"
  28. #include "graphics.h"
  29.  
  30. static    Boolean                gShowingEndGame;
  31. static    PicHandle            gCongratsColorPict, gCongratsBWPict;
  32. static    PicHandle            gWinnerColorPict, gWinnerBWPict;
  33.  
  34. enum
  35. {
  36.     congratsColorID=400,
  37.     congratsBWID,
  38.     winnerColorID,
  39.     winnerBWID
  40. };
  41.  
  42. Boolean GameOverQQ(void)
  43. {
  44.     short            theRow, theColumn;
  45.     
  46.     for (theRow=0; theRow<3; theRow++)
  47.     {
  48.         for (theColumn=gNumColumns-3; theColumn<gNumColumns; theColumn++)
  49.         {
  50.             if (Board[theRow][theColumn]==kNoPiece)
  51.                 return FALSE;
  52.         }
  53.     }
  54.     
  55.     return TRUE;
  56. }
  57.  
  58. void CheckEndGame(WindowDataHandle theData, short theRow, short theColumn)
  59. {
  60.     if (GameOverQQ())
  61.     {
  62.         DoAlreadyHighlighted(theData, theRow, theColumn);
  63.         gShowingEndGame=TRUE;
  64.         DoSound(sound_endgame, TRUE);
  65.         (**theData).offscreenNeedsUpdate=TRUE;
  66.         UpdateTheWindow((ExtendedWindowDataHandle)theData);
  67.     }
  68. }
  69.  
  70. Boolean ShowingEndGameQQ(void)
  71. {
  72.     return gShowingEndGame;
  73. }
  74.  
  75. void DontShowEndGame(WindowDataHandle theData)
  76. {
  77.     gShowingEndGame=FALSE;
  78.     (**theData).offscreenNeedsUpdate=TRUE;
  79.     UpdateTheWindow((ExtendedWindowDataHandle)theData);
  80. }
  81.  
  82. void InitTheEndGame(void)
  83. {
  84.     gCongratsColorPict=gCongratsBWPict=gWinnerColorPict=gWinnerBWPict=0L;
  85.     gShowingEndGame=FALSE;
  86. }
  87.  
  88. void ShutDownTheEndGame(void)
  89. {
  90.     gCongratsColorPict=ReleaseThePict(gCongratsColorPict);
  91.     gCongratsBWPict=ReleaseThePict(gCongratsBWPict);
  92.     gWinnerColorPict=ReleaseThePict(gWinnerColorPict);
  93.     gWinnerBWPict=ReleaseThePict(gWinnerBWPict);
  94. }
  95.  
  96. void EndTheGame(WindowDataHandle theData, int theDepth)
  97. {
  98.     GrafPtr            curPort;
  99.     short            theX, theY;
  100.     Boolean            isColor;
  101.     short            best;
  102.     
  103.     isColor=(theDepth>2);
  104.     GetPort(&curPort);
  105.     theX=gNumColumns*15-42;
  106.     theY=(curPort->portRect.bottom-curPort->portRect.top)/3;
  107.     best=BestSolution();
  108.     if ((gNumMoves<=best) && (best>0))
  109.     {
  110.         if (isColor)
  111.             gWinnerColorPict=DrawThePicture(gWinnerColorPict, winnerColorID, theX, theY);
  112.         else
  113.             gWinnerBWPict=DrawThePicture(gWinnerBWPict, winnerBWID, theX, theY);
  114.     }
  115.     else
  116.     {
  117.         if (isColor)
  118.             gCongratsColorPict=DrawThePicture(gCongratsColorPict, congratsColorID, theX, theY);
  119.         else
  120.             gCongratsBWPict=DrawThePicture(gCongratsBWPict, congratsBWID, theX, theY);
  121.     }
  122. }
  123.